#include <stdio.h>
#include <stdlib.h>

typedef struct node
{
    int data;
    struct node* next;
}LNode;

void Slistpushback(LNode** head,int x)
{
    LNode *newnode;
    LNode *tail;
    tail=*head;
    newnode=(LNode*)malloc(sizeof(LNode));
    newnode->data=x;
    newnode->next=NULL;
    if(*head==NULL)
    {
        *head=newnode;
    }
    else
    {
        while(tail->next!=NULL)
        {
            tail=tail->next;
        }
        tail->next=newnode;
    }
}
void Slisterase(LNode* head,int y)
{
    while(head->data==y)
    {
        head=head->next;
    }
    LNode* cur=head;
    LNode* prev=head;
    while(cur!=NULL)
    {
        if(cur->data==y)
        {
            prev->next=cur->next;
        }
        prev=cur;
        cur=cur->next;
    }
    LNode* tail=head;
    while(tail!=NULL)
    {
        printf("%d ",tail->data);
        tail=tail->next;

    }
}
int main()
{
    int n,x,y;
    while(scanf("%d",&n)!=EOF)
    {
        LNode* plist;
        plist=NULL;
        for(int i=0;i<n;i++)
        {
            scanf("%d",&x);
            Slistpushback(&plist,x);
        }
        scanf("%d",&y);
        Slisterase(plist,y);
    }
    return 0;
}
